#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@Author          : ricsy
@File            : prod_config.py.py
@Create Time     : 2025/6/18 04:41
@Last Modified   :
@Description     :
"""
from theme_customizer.base import BaseCustomizer


class ProductionConfigurator(BaseCustomizer):
    """生产环境配置管理器"""

    PROD_SETTINGS = {
        "show_version_warning_banner": False,
        "surface_warnings": False,
    }

    def apply(self):
        if self.is_production:
            self._apply_prod_settings()
            self.logger.info("已应用生产环境配置", 2)

    def _apply_prod_settings(self):
        """应用生产环境配置"""
        for key, value in self.PROD_SETTINGS.items():
            if hasattr(self.app.config, key):
                setattr(self.app.config, key, value)
            elif key in self.app.config.html_theme_options:
                self.app.config.html_theme_options[key] = value
